
set(CPACK_COMPONENTS_ALL "Runtime")
set(CPACK_COMPONENT_UNSPECIFIED_HIDDEN "TRUE")
set(CPACK_COMPONENT_UNSPECIFIED_REQUIRED "TRUE")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/ABOUT.txt")
#set(CPACK_DEFAULT_PACKAGE_DESCRIPTION_FILE "/usr/share/cmake-3.16/Templates/CPack.GenericDescription.txt")
set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_CURRENT_BINARY_DIR};${CMAKE_PROJECT_NAME};ALL;/")
set(CPACK_PACKAGE_DEFAULT_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/packages")
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/packages")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "GridLAB-D power system simulator")
set(CPACK_PACKAGE_NAME "GridLAB-D")
set(CPACK_PACKAGE_RELOCATABLE "true")

set(CPACK_PACKAGE_VENDOR "Pacific Northwest National Laboratory")
set(CPACK_PACKAGE_CONTACT "gridlabd@pnnl.gov")
set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${REV_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${REV_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${REV_PATCH})

IF (WIN32 OR MSYS OR MINGW OR CYGWIN)
    set(CPACK_NSIS_INSTALLER_ICON_CODE "")
    set(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "")
    set(CPACK_NSIS_INSTALL_ROOT "$PROGRAMFILES")
    set(CPACK_NSIS_MODIFY_PATH "OFF") # TODO: fix the path-too-long error this flag can cause
    set(CPACK_BINARY_ZIP "ON")
    set(CPACK_BINARY_NSIS "ON")
    set(CPACK_NSIS_MODIFY_PATH "ON")
    #    set(CPACK_BINARY_WIX "ON")
    set(CPACK_CMAKE_GENERATOR "Ninja")
    set(CPACK_SOURCE_GENERATOR "ZIP")
    set(CPACK_SOURCE_ZIP "ON")
    set(CPACK_SYSTEM_NAME "Windows")
    set(CPACK_TOPLEVEL_TAG "Windows")
    set(CPACK_WIX_SIZEOF_VOID_P "8")
    set(CPACK_NSIS_MENU_LINKS
            "bin/gridlabd.bat" "GridLAB-D Runner"
            )
ELSEIF (APPLE)
    #    set(CPACK_BUNDLE_NAME ${CPACK_PACKAGE_NAME})
    #    set(CPACK_GENERATOR productbuild)
    set(CPACK_BINARY_OSXX11 "ON")
    set(CPACK_BINARY_STGZ "ON")
    set(CPACK_CMAKE_GENERATOR "Unix Makefiles")
    set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
    set(CPACK_SOURCE_TGZ "ON")
    set(CPACK_SOURCE_ZIP "ON")
    set(CPACK_SYSTEM_NAME "MacOS")
    set(CPACK_TOPLEVEL_TAG "MacOS")
    set(CPACK_WIX_SIZEOF_VOID_P "8")
ELSEIF (UNIX AND NOT APPLE)
    #TODO: CPACK_DEBIAN_PACKAGE_DEPENDS
    set(CPACK_BINARY_DEB "ON")
    set(CPACK_BINARY_RPM "ON")
    set(CPACK_BINARY_STGZ "ON")
    set(CPACK_CMAKE_GENERATOR "Unix Makefiles")
    set(CPACK_SET_DESTDIR "OFF")
    set(CPACK_SOURCE_GENERATOR "TGZ;ZIP")
    set(CPACK_SOURCE_TGZ "ON")
    set(CPACK_SOURCE_ZIP "ON")
    set(CPACK_SYSTEM_NAME "Linux")
    set(CPACK_TOPLEVEL_TAG "Linux")
    set(CPACK_WIX_SIZEOF_VOID_P "8")
ELSE ()
    MESSAGE(WARNING "Platform not recognized, packaging may fail")
ENDIF ()


if (NOT CPACK_PROPERTIES_FILE)
    set(CPACK_PROPERTIES_FILE "${CMAKE_CURRENT_BINARY_DIR}/CPackProperties.cmake")
endif ()

if (EXISTS ${CPACK_PROPERTIES_FILE})
    include(${CPACK_PROPERTIES_FILE})
endif ()


include(CPack)